//
// Created by 高森森 on 2022/1/27.
//

#ifndef LEETCODE_SOLUTION9_H
#define LEETCODE_SOLUTION9_H


class Solution9 {
public:
    int kthGrammar(int n, int k) {
        if(n==1)
            return 0;
        int length=1<<(n-1);
        if(k>length/2){
            int val=kthGrammar(n-1,k-length/2);
            return val==0?1:0;
        }
        else{
            return kthGrammar(n-1,k);
        }
    }
};


#endif //LEETCODE_SOLUTION9_H
